/*
 * SharedObject.h
 *
 *  Created on: 15/03/2011
 *      Author: Nikolaj
 */

#ifndef SHAREDOBJECT_H_
#define SHAREDOBJECT_H_

#include "../OSAPI.h"
#include "Thread_Mutex_Guard.h"

namespace os {
	template < class T >
	class SharedObject {
	public:
		const T& get() const {
			Thread_Mutex_Guard(lock_);
			return data;
		}

		void put(T value) {
			Thread_Mutex_Guard(lock_);
			data = value;
			return;
		}

	private:
		// Serialize access to the critical section.
		Mutex lock_;
		T data;
	};
}
#endif /* SHAREDOBJECT_H_ */
